package com.tarena.lbs.message.web.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.message.web.service.MessageService;
import com.tarena.lbs.pojo.message.query.MessageQuery;
import com.tarena.lbs.pojo.message.vo.MessageVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MessageController {
    @Autowired
    private MessageService messageService;
    @PostMapping("/message/selectAll")
    public Result<List<MessageVO>> selectAll()
        throws BusinessException{
        List<MessageVO> vos=messageService.selectAll();
        return new Result<>(vos);
    }
    @ApiOperation("查询某个用户最新消息")
    @PostMapping("/message/selectUserNewMessage")
    public Result<List<MessageVO>> selectUserNewMessage(@RequestBody MessageQuery messageQuery) {
        List<MessageVO> msgList = messageService.selectUserNewMessage(messageQuery);
        return new Result<>(msgList);
    }
}
